package com.lyx.question.service.impl;

import com.jx.sms.config.SmsType;
import com.jx.sms.core.SmsSendManager;
import com.jx.sms.core.entity.SmsResponse;
import com.jx.sms.core.entity.SmsSend;
import com.lyx.common.exception.BusinessException;
import com.lyx.common.exception.ExceptionEnum;
import com.lyx.common.utils.VerifyCodeUtils;
import com.lyx.question.service.QuestionSmsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils;

import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.TimeUnit;

/**
 * @author 14667
 * @date 2022/8/10 14:16
 */
@Component
public class QuestionSmsServiceImpl implements QuestionSmsService {

    @Autowired
    SmsSendManager sendManager;
    @Autowired
    StringRedisTemplate redisTemplate;


    @Override
    public boolean sendMessage(String phone,Integer paperId) {

        SmsSend smsSend = new SmsSend();
        List<String> phones = new ArrayList<>();
        phones.add(phone);
        smsSend.setPhones(phones);
        smsSend.setType(SmsType.notice);
        smsSend.setContent("您好，您试卷id为"+paperId+"的试卷交卷成功！");
        SmsResponse response = sendManager.send(smsSend);
        if(response.getCode().equals("0")){
            return true;
        }
        return false;
    }


}
